import os
from pprint import pprint
from common.base import *


# 打开浏览器
driver = webdriver.Chrome()
# 请求百度
driver.get('https://www.baidu.com')
# 获得所有cookie信息
driver.get_cookies()
# pprint(driver.get_cookies())

# 返回特定name的cookie信息
driver.get_cookie('BA_HECTOR')
# print(driver.get_cookie('BA_HECTOR'))

# 添加cookie
dict1 = {'name': 'my', 'value': '666'}
driver.add_cookie(dict1)
# pprint(driver.get_cookies())

# 删除指定cookie
driver.delete_cookie('my')
# pprint(driver.get_cookies())

# 删除所有cookie
driver.delete_all_cookies()
pprint(driver.get_cookies())
# 关闭浏览器
sleep(2)
driver.quit()
